<template>
    <div class="order-confirm-wrap">
        <CommonHeader teleport=".header" title="订单确认" left-arrow @click-left="$router.back()"></CommonHeader>
    </div>
</template>

<script setup lang="ts">
import CommonHeader from '@/components/CommonHeader.vue';
import { ref, reactive ,onMounted} from "vue"
import {confirmOrderAPI} from "@/api/order"
import { useUserid } from "@/hooks/useUserid"
import {showFailToast} from "vant";

import {useRoute} from "vue-router";


const { userid } = useUserid();
const route = useRoute();

const confirmOrder = async () => {
    try {
        let result = await confirmOrderAPI({
            userid:userid.value,
            time: route.query.time
        });
        console.log("订单确认信息", result);


        let address = {};

        // 商品列表
        let list= result.data.map((item:any)=>{

            let {name,tel,province,city,county,addressDetail,...goodsInfo} = item;

            address = {name,tel,province,city,county,addressDetail};

            return goodsInfo;
        })

        console.log("地址信息",address);
        console.log("商品信息",list);
        

    } catch (err: any) {
        showFailToast(err.message);
    }
}


onMounted(async ()=>{
    confirmOrder();
})



</script>

<style scoped></style>